import Cookies from 'js-cookie'

const TokenKey = 'X-Token'
const UserKey = 'user'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getUser() {
  const userStr = Cookies.get(UserKey);
  return userStr ? JSON.parse(userStr) : null;
}

export function setUser(user) {
  return Cookies.set(UserKey, JSON.stringify(user))
}

export function removeUser() {
  return Cookies.remove(UserKey)
}
